﻿package view.tips
{
    import com.greensock.*;
    import flash.display.*;
    import flash.utils.*;

    public class BmRunner extends Sprite
    {
        private var timeDic:Dictionary;
        private var delayCountDic:Dictionary;

        public function BmRunner()
        {
            this.timeDic = new Dictionary();
            this.delayCountDic = new Dictionary();
            return;
        }// end function

        public function show(param1:int, param2:int) : void
        {
            var _loc_3:BmRunnerCell = null;
            var _loc_4:TimelineLite = null;
            if (this.checkTime(param1))
            {
                _loc_3 = new BmRunnerCell(param1, int(this.delayCountDic[param1]) + param2);
                this.delayCountDic[param1] = 0;
                _loc_3.scaleX = 1.5;
                _loc_3.scaleY = 1.5;
                this.addChild(_loc_3);
                _loc_4 = new TimelineLite();
                _loc_4.append(TweenLite.to(_loc_3, 1, {scaleX:1, scaleY:1, y:-100, x:-(_loc_3.width >> 1)}));
                _loc_4.append(TweenLite.to(_loc_3, 1, {y:-200}));
                _loc_4.append(TweenLite.to(_loc_3, 1, {alpha:0, onComplete:this.showComplete, onCompleteParams:[_loc_3, _loc_4]}));
            }
            else
            {
                this.delayCountDic[param1] = int(this.delayCountDic[param1]) + param2;
            }
            return;
        }// end function

        public function checkTime(param1:int) : Boolean
        {
            var _loc_2:* = this.timeDic[param1];
            var _loc_3:* = getTimer() + 2000;
            var _loc_4:* = _loc_3 - _loc_2;
            if (_loc_3 - _loc_2 >= 2000)
            {
                this.timeDic[param1] = _loc_3;
                return true;
            }
            return false;
        }// end function

        public function showComplete(param1:BmRunnerCell, param2:TimelineLite) : void
        {
            param2.kill();
            param2 = null;
            this.removeChild(param1);
            param1.destory();
            param1 = null;
            return;
        }// end function

    }
}
